<template>
  <div>
    <mylist :list="list"></mylist>
  </div>
</template>

<script>
import mylist from "@/components/MyList1";
import axios from "axios";
import _ from "lodash";
import { getHostName, api } from "../../../libs/api";

export default {
  created() {
    this.loadData();
  },
  components: {
    mylist
  },
  computed: {
    list() {
      var arr = [];
      _.forEach(this.apiList, item => {
        arr.push({
          name: item.title,
          value: this.makeUrl(item.path)
        });
      });
      return arr;
    }
  },
  data() {
    return {
      apiList: []
    };
  },
  methods: {
    loadData() {
      axios
        .get("/api/swagger", {
          baseURL: "http://" + getHostName() + ":8080"
        })
        .then(res => {
          if (res.data.code == 0) {
            this.apiList = res.data.data;
          }
        });
    },
    makeUrl(val) {
      return `<a href="http://${getHostName()}:8080/swagger/?url=http://${getHostName()}:8080/develop/${val}" target="_blank" >http://${getHostName()}:8080/develop/${val}</a>`;
    }
  }
};
</script>
<style @scoped>
a{
  text-decoration: none;
}
</style>

